package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.R
import com.erp.bean.YuliaoCangweiBean
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_yuliao_cangwei.view.*

class YuliaoCangweiAdapter(var cangweiList: MutableList<YuliaoCangweiBean>, var mcontext: Context) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)
    override fun getView(position: Int, convertView: View?, p2: ViewGroup?): View {
        var v :View
        val vh: ViewHolder
        if (convertView == null) {
            v = minflater.inflate(R.layout.lv_yuliao_cangwei, null)
            vh = ViewHolder(v)
            v.tag = vh
        } else {
            v = convertView
            vh = convertView.tag as ViewHolder
        }
        Myutil.settv(cangweiList[position].name, vh.tvName)
        return v
    }

    override fun getItem(position: Int): Any = cangweiList[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getCount(): Int = cangweiList.size

    internal class ViewHolder(view: View) {
        var tvName=view.tvName

    }
}